---
--GamersArmy.net Main Client code.
--TTT GA mod
---

include("cl_gahud.lua")
include("ga_shared.lua")
include("sh_utime.lua")

function gamenu( ply )
local base = vgui.Create("DFrame")
base:SetSize( 500, 400 ) -- Size of the frame
base:SetTitle( "GamersArmy Menu" ) -- Title of the frame
base:SetDraggable( true ) -- Draggable by mouse?
base:ShowCloseButton( true ) -- Show the close button?
base:Center()
base:MakePopup()
function base:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 90, 90,90))
surface.SetDrawColor( 0, 0, 0)
surface.DrawOutlinedRect( 1, 1, w-2, h-2)
surface.DrawOutlinedRect( 1, 1, w-2, 24)
end  

local Round = vgui.Create("DLabel", base)
Round:SetPos(25,30) // Position
Round:SetColor(Color(255,255,255,255)) // Color
Round:SetFont("default")
Round:SetText("Next round items:") // Text
Round:SizeToContents()

local money = vgui.Create("DLabel", base)
money:SetPos(310,30) // Position
money:SetColor(Color(255,255,255,255)) // Color
money:SetFont("default")
money:SetText("Your current money : $".. ply:GetNWInt("money")) // Text
money:SizeToContents()

local mod = vgui.Create("DLabel", base)
mod:SetPos(310,40) // Position
mod:SetColor(Color(255,255,255,255)) // Color
mod:SetFont("default")
mod:SetText("Your current model is: ".. gamodnamelocal[ply:GetNWInt("model")]) // Text
mod:SizeToContents()

local BuyTbutt = vgui.Create( "DButton" )
BuyTbutt:SetParent(base) -- Set parent to our "DermaPanel"
--BuyTbutt:SetText( "Buy Traitor Round" )
BuyTbutt:SetText( "" )
BuyTbutt:SetTooltip ("Cost: $".. gaTcost)
BuyTbutt:SetPos( 20, 60 )
BuyTbutt:SetSize( 125, 40 )
BuyTbutt.DoClick = function ()
    gabuyclass( ply, "traitor" )
	surface.PlaySound( "UI/buttonclick.wav" )
	 base:Remove()
end
function BuyTbutt:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 120, 120,120))
draw.SimpleText("Buy Traitor Round", "DefaultBold",w/2, h/2, Color(255,255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
end
local BuyDbutt = vgui.Create( "DButton" )
BuyDbutt:SetParent( base ) -- Set parent to our "DermaPanel"
BuyDbutt:SetText( " " )
BuyDbutt:SetTooltip ("Cost: $".. gaDcost)
BuyDbutt:SetPos( 150, 60 )
BuyDbutt:SetSize( 125, 40 )
BuyDbutt.DoClick = function ()
   surface.PlaySound( "UI/buttonclick.wav" )
    gabuyclass( ply, "detective" )
	 base:Remove()
end
function BuyDbutt:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 120, 120,120))
draw.SimpleText("Buy Detective Round", "DefaultBold",w/2, h/2, Color(255,255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
end

local ModleL = vgui.Create("DLabel", base)
ModleL:SetPos(25,320) // Position
ModleL:SetColor(Color(255,255,255,255)) // Color
ModleL:SetFont("default")
ModleL:SetText("Skin items:") // Text
ModleL:SizeToContents()

local ModlesButt = vgui.Create("DButton")
ModlesButt:SetParent( base )
ModlesButt:SetText( "" )
ModlesButt:SetPos(20, 350)
ModlesButt:SetSize( 155, 40 )
ModlesButt.DoClick = function ( btn )
	 surface.PlaySound( "UI/buttonclick.wav" )
    local ModlesButtOptions = DermaMenu() -- Creates the menu
	for i = 1, #gamodnamelocal do
	 ModlesButtOptions:AddOption("Set your model to: "..gamodnamelocal[i].." for the price of $"..gamodprice[i],  function() 
	 RunConsoleCommand("buymodel",gamodnamechat[gamodnamelocal[i]])
	 surface.PlaySound( "UI/buttonclick.wav" )
	 base:Remove()
	 end)
    -- for ref ULib.tsayError( target_plys, gamodnamelocal[i], true )
	end
    	
    ModlesButtOptions:Open() -- Open the menu AFTER adding your options
end	
function ModlesButt:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 120, 120,120))
draw.SimpleText("Change model ^ ", "DefaultBold",w/2, h/2, Color(255,255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
end

local WeaL = vgui.Create("DLabel", base)
WeaL:SetPos(25,120) // Position
WeaL:SetColor(Color(255,255,255,255)) // Color
WeaL:SetFont("default")
WeaL:SetText("Weapons (Per Round!):") // Text
WeaL:SizeToContents()
--base:MakePopup()

local postable = {} 
postable[1] = {
xpos = "20",
ypos = "160",
}
postable[2] = {
xpos = "150",
ypos = "160",
}
postable[3] = {
 xpos = "280",
 ypos = "160",
 }
postable[4] = {
xpos = "20",
ypos = "220",
}
postable[5] = {
xpos = "150",
ypos = "220",
}
postable[6] = {
xpos = "280",
ypos = "220",
}

for i=1,table.Count(weaps) do

	print("-----Weapon----")
	print(weaps[i].name)
	print("Normal cost: $"..weaps[i].prices.reg)
	print("Discount cost: $"..weaps[i].prices.dic)
	print(postable[i].test)
	
    if weaps[i].tonly == true and (not ply:GetTraitor()) then
    return
	end
	if 	ply:IsUserGroup("protected") or ply:IsUserGroup("admin")  or ply:IsUserGroup("superadmin") then
	cost = "Discounted price of $:".. weaps[i].prices.dic
	else
	cost = "Cost: $".. weaps[i].prices.reg
	end
	local BuyGun = vgui.Create( "DButton" )
	BuyGun:SetParent( base ) -- Set parent to our "DermaPanel"
	BuyGun:SetText( " " )
	BuyGun:SetTooltip (cost)
	BuyGun:SetPos( postable[i].xpos, postable[i].ypos )
	BuyGun:SetSize( 125, 40 )
	BuyGun.DoClick = function ()
	RunConsoleCommand("buyweapon",i)
	surface.PlaySound( "UI/buttonclick.wav" )
	base:Remove()
	
end

function BuyGun:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 120, 120,120))
draw.SimpleText(weaps[i].name, "DefaultBold",w/2, h/2, Color(255,255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
end

end

--[[
local BuyG1 = vgui.Create( "DButton" )
BuyG1:SetParent( base ) -- Set parent to our "DermaPanel"
BuyG1:SetText( " " )
BuyG1:SetTooltip ("Cost: $100")
BuyG1:SetPos( 20, 160 )
BuyG1:SetSize( 125, 40 )
BuyG1.DoClick = function ()
surface.PlaySound( "UI/buttonclick.wav" )
	 base:Remove()
end
function BuyG1:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 120, 120,120))
draw.SimpleText("Buy #gun#", "DefaultBold",w/2, h/2, Color(255,255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
end
local BuyG2 = vgui.Create( "DButton" )
BuyG2:SetParent( base ) -- Set parent to our "DermaPanel"
BuyG2:SetText( " " )
BuyG2:SetTooltip ("Cost: $100")
BuyG2:SetPos( 20, 220 )
BuyG2:SetSize( 125, 40 )
BuyG2.DoClick = function ()
	 base:Remove()
	 surface.PlaySound( "UI/buttonclick.wav" )
end
function BuyG2:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 120, 120,120))
draw.SimpleText("Buy #gun#", "DefaultBold",w/2, h/2, Color(255,255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
end



local BuyG3 = vgui.Create( "DButton" )
BuyG3:SetParent( base ) -- Set parent to our "DermaPanel"
BuyG3:SetText( " " )
BuyG3:SetTooltip ("Cost: $100")
BuyG3:SetPos( 150, 160 )
BuyG3:SetSize( 125, 40 )
BuyG3.DoClick = function ()
	 base:Remove()
	 surface.PlaySound( "UI/buttonclick.wav" )
end
function BuyG3:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 120, 120,120))
draw.SimpleText("Buy #gun#", "DefaultBold",w/2, h/2, Color(255,255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
end
local BuyG4 = vgui.Create( "DButton" )
BuyG4:SetParent( base ) -- Set parent to our "DermaPanel"
BuyG4:SetText( " " )
BuyG4:SetTooltip ("Cost: $100")
BuyG4:SetPos( 150, 220 )
BuyG4:SetSize( 125, 40 )
BuyG4.DoClick = function ()
	 base:Remove()
	 surface.PlaySound( "UI/buttonclick.wav" )
end
function BuyG4:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 120, 120,120))
draw.SimpleText("Buy #gun#", "DefaultBold",w/2, h/2, Color(255,255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
end

local BuyG5 = vgui.Create( "DButton" )
BuyG5:SetParent( base ) -- Set parent to our "DermaPanel"
BuyG5:SetText( " " )
BuyG5:SetTooltip ("Cost: $100")
BuyG5:SetPos( 280, 160 )
BuyG5:SetSize( 125, 40 )
BuyG5.DoClick = function ()
	 base:Remove()
	 surface.PlaySound( "UI/buttonclick.wav" )
end
function BuyG5:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 120, 120,120))
draw.SimpleText("Buy #gun#", "DefaultBold",w/2, h/2, Color(255,255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
end
local BuyG6 = vgui.Create( "DButton" )
BuyG6:SetParent( base ) -- Set parent to our "DermaPanel"
BuyG6:SetText( " " )
BuyG6:SetTooltip ("Cost: $100")
BuyG6:SetPos( 280, 220 )
BuyG6:SetSize( 125, 40 )
BuyG6.DoClick = function ()
	 base:Remove()
	 surface.PlaySound( "UI/buttonclick.wav" )
end
function BuyG6:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 120, 120,120))
draw.SimpleText("Buy #gun#", "DefaultBold",w/2, h/2, Color(255,255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
end
--]]
end
--end








--[[Old Menu
function gamenu( ply )
ply = LocalPlayer()
local DermaPanel = vgui.Create( "DFrame" ) -- Creates the frame itself
   DermaPanel:SetPos( 50,50 ) -- Position on the players screen
   DermaPanel:SetSize( 500, 400 ) -- Size of the frame
   DermaPanel:SetTitle( "GamersArmy Menu" ) -- Title of the frame
   DermaPanel:SetVisible( true )
   DermaPanel:SetDraggable( true ) -- Draggable by mouse?
   DermaPanel:ShowCloseButton( true ) -- Show the close button?
   DermaPanel:SizeToContents()
   DermaPanel:SetContentAlignment( 5 )


   --local w, h = DermaPanel:GetSize()
   --local m = 10
   --DermaPanel:SetPos(m,m)
   --DermaPanel:SetSize( w + m*5, h + m*5 )
   DermaPanel:Center()
   --DermaPanel:AlignBottom( 10 )
   local DermaButton = vgui.Create( "DButton" )
DermaButton:SetParent( DermaPanel ) -- Set parent to our "DermaPanel"
DermaButton:SetText( "Buy Traitor Round" )
DermaButton:SetPos( 20, 60 )
DermaButton:SetSize( 110, 40 )
DermaButton.DoClick = function ()
    gabuyclass( ply, "traitor" )
	 DermaPanel:Remove()
end
   local DermaButton2 = vgui.Create( "DButton" )
DermaButton2:SetParent( DermaPanel ) -- Set parent to our "DermaPanel"
DermaButton2:SetText( "Buy Detective Round" )
DermaButton2:SetPos( 150, 60 )
DermaButton2:SetSize( 110, 40 )
DermaButton2.DoClick = function ()
    gabuyclass( ply, "detective" )
	 DermaPanel:Remove()
end

local myLabel = vgui.Create("DLabel", DermaPanel)
myLabel:SetPos(170,25) // Position
myLabel:SetColor(Color(255,255,255,255)) // Color
myLabel:SetFont("default")
myLabel:SetText("GamersArmy.net Buy Menu") // Text
myLabel:SizeToContents()

local money1 = vgui.Create("DLabel", DermaPanel)
money1:SetPos(190,100) // Position
money1:SetColor(Color(255,255,255,255)) // Color
money1:SetText("$100") // Text
money1:SizeToContents()
local money2 = vgui.Create("DLabel", DermaPanel)
money2:SetPos(60,100) // Position
money2:SetColor(Color(255,255,255,255)) // Color
money2:SetText("$150") // Text
money2:SizeToContents()



local ModlesButt = vgui.Create("DButton")
ModlesButt:SetParent( DermaPanel )
ModlesButt:SetText( "Change model >" )
ModlesButt:SetPos(20, 350)
ModlesButt:SetSize( 155, 40 )
ModlesButt.DoClick = function ( btn )
    local ModlesButtOptions = DermaMenu() -- Creates the menu
	for i = 1, #gamodnamelocal do
	 ModlesButtOptions:AddOption("Set your model to: "..gamodnamelocal[i].." for the low price of $"..gamodprice[i],  function() 
	 RunConsoleCommand("buymodel",gamodnamechat[gamodnamelocal[i]]--[[)
	 DermaPanel:Remove()
	 end)
    -- for ref ULib.tsayError( target_plys, gamodnamelocal[i], true )
	end
    	
    ModlesButtOptions:Open() -- Open the menu AFTER adding your options
end	

     draw.NoTexture()
     surface.SetDrawColor( 70,70,70,255 )
     surface.DrawRect( 50,50,400,30 ) --main square
     surface.SetDrawColor( 70,70,70,255 )
     surface.DrawRect( w-2,0,h,2 ) --borders
     surface.DrawRect( 0,h-2,2,w ) -- ^
DermaPanel:MakePopup()
end
]]--



concommand.Add("GaMenu", gamenu)

